package com.example.user.service.application.service;

import com.example.user.service.application.command.UpdateUserCommand;
import com.example.user.service.application.port.in.UpdateUserUseCase;
import com.example.user.service.domain.User;
import com.example.user.service.domain.port.UpdateUserPort;
import com.example.user.service.domain.valueobject.Email;
import com.example.user.service.domain.valueobject.UserAge;
import com.example.user.service.domain.valueobject.UserId;
import com.example.user.service.domain.valueobject.UserName;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class UpdateUserService implements UpdateUserUseCase {
    @Resource
    private UpdateUserPort updateUserPort;

    @Override
    public User updateUser(UpdateUserCommand command) {
        User user = new User(
                new UserId(command.id()),
                new UserName(command.name()),
                new UserAge(command.age()),
                new Email(command.email()));
        return updateUserPort.updateUser(user);
    }
}
